草庐IT

【HDLBits刷题笔记】01 Getting Started & Basics

全部标签

ruby-on-rails - bundle 安装错误,意外 ':'

我知道网上有很多问题或类似问题,但它不适合我的情况。我正在安装redmine,当我调用bundleinstall时,出现此错误:[!]Therewasanerrorparsing`Gemfile`:compileerror-syntaxerror,unexpected':',expecting$endgem'tzinfo-data',platforms:[:mingw,:x64_mingw,:mswin,:jruby]^.Bundlercannotcontinue.错误在这一行(以->为前缀的那一行):source'https://rubygems.org'ifGem::Version

ruby - gem 更新——系统返回 "no implicit conversion of nil into String"

运行gemupdate--system不断返回错误#gemupdate--systemUpdatingrubygems-updateERROR:Whileexecutinggem...(TypeError)noimplicitconversionofnilintoString如何解决?详细:http://pastebin.com/2uBYEMTi 最佳答案 这可能是由于不兼容的gem版本(也许是一个正在做Monkey补丁的gem?)。您可以尝试更新单个gem吗? 关于ruby-gem更新

ruby-on-rails - 即使在编辑模式下,rails 嵌套形式始终为 "POST"?导致路由错误

我正在开发一个应用程序有1个具有多对多关系的模块,它工作正常,我可以用嵌套形式创建我的“单元”,但是当我处于编辑状态时我遇到了1个问题,当我点击提交按钮时它抛出了一个错误。Noroutematches[POST]"/units/27"ithoughttheactionshouldbepatchinsteadofpost??iinspectthegeneratedhtmlinbrowsers,andicanseethereisahiddenfieldnamed"_method"with"patch"value.我用脚手架生成了这个模块单位模型classUnit:unitrentperio

ruby - 如何静默启动 Sinatra + Thin?

我有一个Sinatra::Base网络服务,我想从命令行Ruby程序启动它,所以我有这个:#commandlineprogramfilerequire'mymodule/server'puts"Runningon0.0.0.0:4567,debuggingtoSTDOUT..."MyModule::Server.run!bind:'0.0.0.0',port:4567,environment::production这按预期工作但抛出:$myscriptRunningon0.0.0.0:4567,debuggingtoSTDOUT...==Sinatra/1.3.1hastakenthe

ruby-on-rails - 使用 Unicorn + Rack 进行带外垃圾收集

我正尝试在我的RubyonRails应用程序中运行带外垃圾收集(一旦请求完成响应)。我在config.ru中添加了以下内容:#ThisfileisusedbyRack-basedserverstostarttheapplication.require::File.expand_path('../config/environment',__FILE__)beginrequire'unicorn/oob_gc'rescueLoadError,NameErrorend#Out-of-bandGC,runsGCafterevery10threquestandaftertheresponse#h

ruby - 在 Ruby 中,当没有正确的英语 "<verb>able"时,mixins 的命名约定是什么?

示例:我有一个Person类和一个Role类。我想将Role和Person中的角色功能提取到混合中。我得到了两个mixins:Actable包含在Role中,Adaptable用于Person。我有时想不出合适的英文单词。在上面的例子中,适应性似乎更适合角色而不是人,因为角色可以适应,因此是适应性强的。一个更好的名字是versatile但这打破了mixin名字以...able结尾的惯例。(虽然它仍然是一个形容词。)另一个例子是当我想添加一个允许检查的模块时,如果一个人被允许查看其他人。你如何找到以...结尾的名字?Viewable似乎不合适,可以查看的人应该是可见的。我现在坚持使用sh

ruby-on-rails - pg_search 使用 associated_against 给出错误 "column [model_name].[associated_column_name] does not exist"

我正在尝试使用pg_search来搜索关联模型。当我运行搜索时,出现错误“PG::Error:ERROR:columnplans.namedoesnotexist”。我正在“计划”模型中运行搜索,并尝试针对“地点”与列“名称”的关联进行搜索。连接这些的has_many:through模型是多态的。不知何故,sql查询将两者结合起来并抛出错误。我已经运行了associated_against迁移(railsgpg_search:migration:associated_against),搜索了文档,并寻找其他有错误的人,但一无所获,一定是我只是忽略了一些东西。如果我只是删除plan.rb

ruby - Rails 3 db :migrate 的未定义方法 `visitor'

我在Rails3中进行数据库迁移时遇到异常。undefinedmethod`visitor'for#编辑请查看解决方案here.在我的项目中没有出现字符串visitor所以我很困惑。这是完整的转储:$rakedb:migrate--trace**Invokedb:migrate(first_time)**Invokeenvironment(first_time)**Executeenvironment**Invokedb:load_config(first_time)**Invokerails_env(first_time)**Executerails_env**Executedb:l

ruby-on-rails - 运行 "bin/rake assets:precompile"时未设置 I18n 加载路径!

我正在使用I18n-js,我的客户端I18n.t调用在生产环境中运行时都会返回翻译缺失消息。开发测试一切正常。这个问题的根源似乎在于Assets管道。I18n.load_path不包含我的任何翻译(当运行bin/rakeassets:precompile时)它只包含以下路径:["/home/chris/.rvm/gems/ruby-1.9.3-p125@Project/gems/activesupport-3.2.3/lib/active_support/locale/en.yml","/home/chris/.rvm/gems/ruby-1.9.3-p125@Project/gems

ruby-on-rails - Ruby on Rails + 设计 + I18n : how to set locale?

我在ApplicationController中使用before_filter为我的应用程序设置语言环境:classApplicationController它适用于我编写的Controller。但是所有devise的消息仍然是英文。在config/application.rb中设置config.i18n.default_locale="uk"(或其他)有效,所以我猜问题在于设计的Controller确实不要使用我的before_filter(可能它根本不继承ApplicationController(?))。如何解决这个问题?如何让设计使用我的语言环境?